package cn.tedu.boot06.controller;

import cn.tedu.boot06.entity.Product;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class AxiosController {
    @RequestMapping("/helloAxios")
    public String helloAxios(String name, int age) {
        return "测试成功!" + name + ":" + age;
    }
    /*
       如果是异步请求并且提交的参数时自定义的js对象,
       服务器接收参数时必须添加@RequestBody注解
       否则接收不到参数
     */
    @RequestMapping("/postAxios")
    public String postAxios(@RequestBody Product product){
        System.out.println("product = " + product);
        return "post请求成功!";
    }
}
